/**
 * king
 */
package cn.scau.info.chao;

/**
 * @author king
 *
 */
public class Coordinate {
	private double x;
	private double y;

	public Coordinate() {
		this(1.0, 1.0);
	}

	public Coordinate(double x, double y) {
		this.x = x;
		this.y = y;
	}

	public Coordinate(int x, int y) {
		this.x = (double) x;
		this.y = (double) y;
	}

	/**
	 * @return the x
	 */
	public double getX() {
		return x;
	}

	/**
	 * @param x
	 *            the x to set
	 */
	public void setX(double x) {
		this.x = x;
	}

	/**
	 * @return the y
	 */
	public double getY() {
		return y;
	}

	/**
	 * @param y
	 *            the y to set
	 */
	public void setY(double y) {
		this.y = y;
	}

	public static double getDistance(Coordinate a, Coordinate b) {
		if (a != null && b != null)
			return Math.pow(
					Math.pow((a.x - b.x), 2) + Math.pow((a.y - b.y), 2), 0.5);
		System.out.println("error: Coordinate can't be null");
		return 0;
	}
}
